package oop.core.parsers;

import java.util.ArrayList;
import java.util.List;

import oop.core.entity.Avatar;
import oop.core.entity.DerivedStats;
import oop.core.entity.Occupation;
import oop.core.entity.OccupationLibrary;
import oop.core.entity.Stats;
import oop.core.item.Equipment;
import oop.core.item.EquippableItem;
import oop.core.item.EquippableItemPosition;
import oop.core.item.Inventory;
import oop.core.map.Location;
import oop.core.map.MovementType;
import oop.core.view.ImageHandler;

/**
 * used to test the AvatarParser and related classes.
 * @author srhinson
 *
 */
public class ParserTest {
	public static void main(String[] args){
		OccupationLibrary.init();
		ImageHandler.loadImages();
		String occupationName;
		DerivedStats stats;
		List<MovementType> movementTypes = new ArrayList<MovementType>();
		occupationName = "Smasher";
		stats = new DerivedStats(0, 5, 100, 100, 3, 2, 1, 3, 4250L);
		movementTypes.add(MovementType.swim);
		movementTypes.add(MovementType.walk);
		
		Occupation occupation = OccupationLibrary.getFromLibrary(occupationName);
		Avatar avatar = new Avatar(0, occupation, occupationName, occupationName, 8, new Location(30, 30), true,
										new Equipment(), new Inventory(), movementTypes, stats);
		System.out.println(avatar.getMoney()+" "+avatar.getOcc().getName()+ " ");
		String avdata = AvatarParser.parseOut(avatar);
		System.out.println(avdata);
		System.out.println("avatar written");
		
		Avatar avatar2 = AvatarParser.parseIn(avdata);
		System.out.println("avatar read");
		System.out.println(avatar2.getMoney() + "A~" + avatar2.getOcc() + "O~");
		String data2 = AvatarParser.parseOut(avatar2);
		if(avdata==data2){
			System.out.println("stupid check: okay");
		}
		Equipment eq = new Equipment();
		List<String> occupationList = new ArrayList<String>();
		occupationList.add("Sneak");
		occupationList.add("Smasher");
		EquippableItem eqI = new EquippableItem("anItemName", "theItemsID", 50, stats, occupationList, EquippableItemPosition.Head, "OneHanded");
		eq.equipItem(eqI);
		Avatar avatar3 = new Avatar(0, occupation, occupationName, occupationName, 8, new Location(30, 30), true,
										eq, new Inventory(), movementTypes, stats);
		System.out.println(avatar.getMoney()+" "+avatar.getOcc().getName()+ " ");
		EquipmentParser.parseOut(avatar3.getEquipment());
	}
}
